package com.example;

/**
 * @desc:
 * @author: Shoko
 * @date: 2025/6/1
 */
// 电梯类
class Elevator {
    private int currentFloor = 1;
    private ElevatorState state;
    private Integer destinationFloor;

    public Elevator() {
        this.state = new IdleState(this);
    }

    public void changeState(ElevatorState state) {
        this.state = state;
    }

    public int getCurrentFloor() {
        return currentFloor;
    }

    public void setCurrentFloor(int currentFloor) {
        this.currentFloor = currentFloor;
    }

    public Integer getDestinationFloor() {
        return destinationFloor;
    }

    public void setDestinationFloor(Integer destinationFloor) {
        this.destinationFloor = destinationFloor;
    }

    public void moveToFloor(int floor) {
        state.moveToFloor(floor);
    }

    public void openDoor() {
        state.openDoor();
    }

    public void closeDoor() {
        state.closeDoor();
    }

    public void markFault() {
        state.markFault();
    }

    public void fixFault() {
        state.fixFault();
    }

    @Override
    public String toString() {
        return "电梯当前位于 " + currentFloor + " 层，状态: " + state.getClass().getSimpleName();
    }
}
